package com.woniu.scss.controller;

import com.woniu.common.utils.PageParam;
import com.woniu.common.utils.ResponseData;
import com.woniu.scss.dto.AddrDTO;
import com.woniu.scss.dto.OrderSearchDTO;
import com.woniu.scss.dto.SendOutDTO;
import com.woniu.scss.feign.CustomerFeign;
import com.woniu.scss.pojo.Order;
import com.woniu.scss.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * packageName com.woniu.scss.controller
 *
 * @author zxyang3636
 * @version JDK 8
 * @className OrderController
 * @date 2024/8/7
 * @description TODO
 */
@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;

    @Autowired
    private CustomerFeign customerFeign;

    @GetMapping("/selPayMethod")
    public ResponseData<?> selPayMethod() {
        return orderService.selPayMethod();
    }

    @PostMapping("/searchOrderByCondition")
    public ResponseData<?> searchOrderByCondition(@RequestBody PageParam<OrderSearchDTO> pageParam) {
        return orderService.searchOrderByCondition(pageParam);
    }

    @GetMapping("/selOrderDetail")
    public ResponseData<?> selOrderDetail(@RequestParam("orderId") String orderId) {
        return orderService.selOrderDetail(orderId);
    }

    @GetMapping("/selUserAddr")
    public ResponseData<?> selUserAddr(@RequestParam("addressId") String addressId) {
        AddrDTO addrDTO = customerFeign.selUserAddrById(addressId);
        return new ResponseData<>().success(addrDTO);
    }

    @GetMapping("/handleDispatchList")
    public ResponseData<?> handleDispatchList(@RequestParam("orderId") String orderId) {
        return orderService.handleDispatchList(orderId);
    }

    @GetMapping("/handleDeliverGoods")
    public ResponseData<?> handleDeliverGoods(@RequestParam("orderId") String orderId) {
        return orderService.handleDeliverGoods(orderId);
    }


    @PostMapping("/sendOut")
    public ResponseData<?> sendOut(@RequestBody SendOutDTO SendOutDTO) {
        return orderService.sendOut(SendOutDTO);
    }

    @PostMapping("/addOrderFromZy")
    public ResponseData<?> addOrderFromZy(@RequestBody String orderMessage){
        return orderService.addOrderFromZy(orderMessage);
    }

    @PostMapping("/shouhouChangeOrderStatus")
    public boolean shouhouChangeOrderStatus(@RequestBody String orderId){
        return orderService.shouhouChangeOrderStatus(orderId);
    }

    @PostMapping("/quxiaoShouhouChangeOrderStatus")
    public boolean quxiaoShouhouChangeOrderStatus(@RequestBody String orderId){
        return orderService.quxiaoShouhouChangeOrderStatus(orderId);
    }

    @GetMapping("/shouhuoFromZy")
    public boolean shouhuoFromZy(String orderId,String orderDetailId){

        return orderService.shouhuoFromZy(orderId,orderDetailId);
    }

}
